using System.Collections;
using System.Collections.Generic;
using MEC;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
using YooAsset;

public class TestTwoBaseUI : BaseUI
{
    private TextMeshProUGUI TwoTxtPro;
    private Button btn_goMain;
    private TestUITwoDTO TTDTO;
    public override EnumUIType GetUIType()
    {
        return EnumUIType.TestUITwo;
    }

    void Start()
    {
        mWndObject = this.gameObject;
        TwoTxtPro = Control("TwoTxtPro").GetComponent<TextMeshProUGUI>();
        btn_goMain = Control("Two-btn").GetComponent<Button>();

        TwoTxtPro.text = "canbeload";
        btn_goMain.onClick.AddListener(ClicTest);

        TestBaseUIOneTest oneui = UIManager.instance.TryGetUI<TestBaseUIOneTest>(EnumUIType.TestPanel_1);
        Debug.Log(oneui.gameObject.name);
        Timing.RunCoroutine(TestUIResult());

    }

    IEnumerator<float> TestUIResult()
    {
        yield return Timing.WaitForSeconds(0.5f);
        TwoTxtPro.text = TTDTO.content;

    }

    private void ClicTest()
    {
        GameObject.FindWithTag("LoadCanvas").GetComponent<SceneManager>().OpenScene(Defines.TestJsonScene);
    }

    protected override void SetUI(Dictionary<EnumUIType, object> uiParams)
    {
        base.SetUI(uiParams);

        if (uiParams.TryGetValue(EnumUIType.TestUITwo,out object value) && value is TestUITwoDTO _ttdto)
        {
            TTDTO = _ttdto;
        }
    }
}
